extends "../cTDZ_1_1/cTDZ_1_1.gd"
func _info():
	pass
func _connect():
	._connect()

func _extInit():
	._extInit()
	chaName = "软泥王"
	lv = 3
	attCoe.atkRan = 1
	attCoe.atk = 20 / 8.5 * 2 / 3
	attCoe.maxHp = 1150 / 112.5 / 3
	attCoe.def = 115 / 15.0 / 2
	attCoe.mgiDef = 115 / 16.6 / 2 
	addCdSkill("rnw1",10)
	addSkillTxt("软泥吞噬：吞噬前方敌方造成200点真伤；如果敌方血量少于20%，则直接斩杀[cd:10秒]")
	addSkillTxt("软泥分裂：死亡后分裂成四个小软泥[召唤位置为地图四个角落，血量为200点，10秒后若有一个存活，则复活自身，并恢复10%血量][受禁止复活影响][cd:35秒]<固化>")
var recnt = 0
var flag = 1
var endflag = 0
func _onBattleStart():
	._onBattleStart()
	recnt = 0
	flag = 1
	endflag = 0 
func _onBattleEnd():
	._onBattleEnd()
	endflag = 1
func _castCdSkill(id):
	._castCdSkill(id)
	if id == "rnw1" && aiCha != null:
		cst("软泥吞噬","000000",position)
		if aiCha.att.hp / aiCha.att.maxHp > 0.2:
			hurtChara(aiCha,200,Chara.HurtType.REAL,Chara.AtkType.SKILL)
		else:
			cst("被斩杀","FF0000",aiCha.position)
			hurtChara(aiCha,aiCha.att.hp * 2,Chara.HurtType.REAL,Chara.AtkType.EFF)
func _onDeath(atkinfo):
	._onDeath(atkinfo)
	if atkinfo.hitCha != self:return
	if flag:
		#self.isDeath = false
		#print(att.hp)
		#print(att.maxHp)
		#plusHp(att.maxHp * 0.5)
		#print(att.hp)
		cst("软泥分裂","000000",position)
		var vps = [Vector2(0,0),Vector2(9,0),Vector2(0,5),Vector2(9,5)]
		for i in range(4):
			var ncha = newChara("cTDZ_1",vps[i])
			if ncha:
				ncha.fa = self
				ncha.attInfo.maxHp = 200.0
				ncha.upAtt()
		var cds = 10
		if sys.test:cds = 2
		yield(sys.get_tree().create_timer(cds),"timeout")
		if !self.canre:return
		if endflag:return
		var chas = getAllChas(2)
		var waitdel = []
		for i in chas:
			if !i:continue
			if i.get("fa") == self:
				waitdel.append(i)
		if waitdel.size():
			self.isDeath = false
			revive(att.maxHp * 0.1)
			healCha(self,att.maxHp * 0.1)
			for i in waitdel:
				i.delself()
			flag = 0


func _upS():
	._upS()
	if !flag:
		recnt += 1
		if recnt % 35 == 0:
			flag = 1
			recnt = 0 